<template>
  <page-layout :desc="desc" :title="title" :linkList="linkList">
    <div slot="extra" class="extraImg">
      <img :src="extraImage"/>
    </div>
    <transition name="page-toggle">
      <keep-alive v-if="multipage">
        <router-view ref="page" />
      </keep-alive>
      <router-view ref="page" v-else />
    </transition>
  </page-layout>
</template>

<script lang="ts">
import { Vue, Component, Prop } from 'vue-property-decorator'
import PageHeader from './PageHeader.vue'
import PageLayout from './PageLayout.vue'

@Component({
  components: {PageLayout, PageHeader}
})
export default class PageView extends Vue {
  public title: string = ''
  public desc: string = ''
  public linkList: any[] = []
  public extraImage: string = ''

  get multipage() {
    return this.$store.state.setting.multipage
  }

  public mounted() {
    this.getPageHeaderInfo()
  }
  public updated() {
    this.getPageHeaderInfo()
  }

  public getPageHeaderInfo() {
    this.title = this.$route.name || ''
    const page: any = this.$refs.page
    if (page) {
      this.desc = page.desc
      this.linkList = page.linkList
      this.extraImage = page.extraImage
    }
  }
}
</script>

<style lang="less" scoped>
  .extraImg{
    margin-top: -60px;
    text-align: center;
    width: 195px;
    img{
      width: 100%;
    }
  }
</style>
